作者:瑞风大姑娘_214 | 来源:互联网 | 2023-08-04 15:15
What happened?
Generate is turning the following schema:
1 2 3 4 5 6 7
| type Post {
id: Int!
}
type Article {
posts: [Post!]!
} |
into:
1 2 3 4 5 6 7
| type Post struct {
ID int `json:"id"`
}
type Article {
Posts []*Post `json:"posts"`
} |
What did you expect?
I expected the following generated types, which has been the case with previous versions:
1 2 3 4 5 6 7
| type Post struct {
ID int `json:"id"`
}
type Article {
Posts []Post `json:"posts"`
} |
That is, I expected
to become
not
. I cannot tell whether this is intentional, based on #710 and #711, or not.
Minimal graphql.schema and models to reproduce
See above.
versions
? 0.9.0
? 1.12.0
- dep or go modules? go modules
该提问来源于开源项目:99designs/gqlgen
This was intentional, see #710
It makes gqlgen more consistent with other codegen tools like prisma and protobuffer and generally reduces boilerplate.
See also #375 (comment)
I am using Prisma and the methods always return a slice of structs, not pointers, so I have to retype it every time, or am I doing something wrong? My issue: (https://github.com/99designs/gqlgen/issues/738)